function imcr = cropImage(imbw)
% Gets cropped image according to its largest bounding box.
% imbw: binary image (0 indicates background)

    bb = regionprops(imbw, 'BoundingBox');
    areas = cellfun(@(v) v(3) * v(4), {bb.BoundingBox}, 'UniformOutput', true);
	[~, idx] = max(areas);
	imcr = imcrop(imbw, bb(idx).BoundingBox);
